package dao;

import java.sql.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class insert {
	//private Connection con;
	public String InsertMessage(Connection connection, HttpServletRequest request,HttpServletResponse response) throws Exception {
		String name = null;
		//Connection con =null;
		//String alamat = null;
		//String join = null;
		try {
			name = request.getParameter("name");
			PreparedStatement ps = connection.prepareStatement("INSERT INTO pesan(message) VALUES(?)");
			//Statement st=con.createStatement();
			ps.setString(1, name);
		//	ps.setString(2, alamat);
			int rs = ps.executeUpdate();
            //String sql2="INSERT INTO tabel(nama) VALUES ('"+name+"')";
            //int rs = st.executeUpdate(sql2);
            //st.close();
			//System.out.println("output="+name+" "+alamat);
			//join = name+"-"+alamat;
			if (rs>0) {
				return name;
			} else {
				return null;
			}
		} catch (Exception e) {
			throw e;
		}
	}
	
	/*public static  void main(String srgv[]) throws Exception{
		db app=new db();
        app.dbOpen();
    }*/
}
